package online_exams.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import online_exams.domain.TUserEntity;
import org.apache.ibatis.annotations.Select;

/**
 * 用户信息表(TUser)表数据库访问层
 *
 * @author makejava
 * @since 2024-12-19 16:49:59
 */
@Mapper
public interface TUserMapper extends BaseMapper<TUserEntity> {

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<TUserEntity> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<TUserEntity> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<TUserEntity> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<TUserEntity> entities);

    //登录
    @Select("select * from t_user where id_number=#{idNumber}")
    TUserEntity login(TUserEntity userEntity);
    //注册
    @Insert("insert into t_user(real_name,id_number,password,email,role) values(#{realName},#{idNumber},#{password},#{email},#{role})")
    Integer studentinsert(TUserEntity tUserEntity);
    //查询是否有此学生
    @Select("select id_number from t_user where id_number=#{idNumber}")
    TUserEntity GetStudentId(String studentId);
    //个人信息
    @Select("select * from t_user where id=#{loginId}")
    TUserEntity getUserInfo(Object loginId);
}

